<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="../images/favicon.ico" type="image/x-icon" />
<title>Velin Georgiev Blog admin page - Web applications developement, ASP.NET, SharePoint, Python, SQL</title>
<meta name="description" content="Velin's blog contains topics related to web applications developement, agile developement, new technologies, workarounds and tutorials based on ASP.NET, Python, SharePoint, MVC, SQL, T-SQL">
<meta name="robots" content="nofollow">
<link type="text/css" rel="stylesheet" href="../stylesheets/main-grey.css" />
<script type="text/javascript" src="https://www.google.com/jsapi?key=ABQIAAAALaBYjHTT3MscB32QQ5om3hS3YBVzhUhNvM0yrSz-CK8h7wVqSBQsqNXabK-ORWN2cIAsZB9x3no9eQ"></script>
<script type="text/javascript" src="../js/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="../js/tiny_mce_init.js"></script>
<script type="text/javascript" src="../js/custom.js" ></script>
<script type="text/javascript">	
	google.load("jquery", "1.6.4");
	google.load("jqueryui", "1.8.16");    

	function OnLoad(){
		var cat = getParameter('cat');
		var cat_list = document.getElementById('cat');
		if (cat){
			for (i=0; i<cat_list.options.length; i++)
			{
				if (cat_list.options[i].text == cat.replace("+"," ")) {
					document.getElementById('cat').options.selectedIndex = i;
				}
			}
		}
	}

	function editComment(strModifyAction, strCommentID){
		$('#comments_modify_action').val(strModifyAction);
		$('#comment_id').val(strCommentID);
		//Some epic client side validation
		var comment_ = "#comment_"+strCommentID.toString()
		if ($(comment_).val()){
			$('#edit_comment').submit();
		}else{
			alert("The Comment field is mandatory.");
			$(comment_).focus();
		}
	}
	
	function editPost(strModifyAction){
		$('#posts_modify_action').val(strModifyAction);
		//Some epic client side validation
		if ($('#title').val() && ($('#content').val() || tinyMCE.get('content').getContent())){
			$('#edit_post').submit();
		}else{
			alert("The Title and Content fields are mandatory.");
			$('#title').focus();
		}
	}
	
	function newPost(){
		//Some epic client side validation
		if ($('#title').val() && ($('#content').val() || tinyMCE.get('content').getContent())){
			$('#new_post').submit();
		}else{
			alert("The Title and Content fields are mandatory.");
			$('#title').focus();
		}
	}

	google.setOnLoadCallback(OnLoad);
</script>
</head>
<body style="width:95%;">
<noscript>JavaScript Disabled. Please enable JavaScript!</noscript>
<table>
	<tr>
	<td id="main_column_1" style="vertical-align:top;">
		<br/><a href="/administrator/" >New Post</a><br/><br/>
		Article Titles<br/>Categories 
		<form action="/administrator/" id="posts_list" method="get" >
			<div>
				<select id="cat" name="cat" onchange="$('#posts_list').submit();" >
					<option selected>All</option>
					{% for item in categories %}
						<option>{{item}}</option>
					{% endfor %}
				</select>
			<div>
			<div id="div_links">
				{{titles_list|safe}}
			</div>
		</form>						
	</td>
	<td id="main_column_2" style="width:80%;">
	{% if post_id %}			
		<form action="/administrator/edit_post" id="edit_post" method="post" />	
			<div>
				<label id="lbl_title">Article ID: {{ article_id }}</label><br/>
				<label id="lbl_title">Title: </label><br/>
				<textarea id="title" name="title" style="width:100%;">{{ post_id.title }}</textarea><br/>
				<label id="lbl_category" >Category: </label><br/>
				<input type="text" id="category" name="category" style="min-width:50%;" value="{{ post_id.category }}" /><br/>
				<label id="lbl_content" >Content: </label>
			</div>
			<div id="posts">
				<textarea id="content" name="content" style="width:100%;min-height:400px;">{{ post_id.content }}</textarea>
				<div class="label-tag-small">Hint:if you would like to write a code block you should enclose your code between &lt;code class="prettyprint linenums"&gt;YourCodeHere&lt;/code&gt; in the HTML plugin of the text editor</div><br/>
				<a href="javascript:;" onmousedown="editPost('Save');" >[Save]</a> |
				<a href="javascript:;" onmousedown="editPost('Delete');">[Delete]</a>
				| [Set Visible] {{ visibiliy|safe }}	<br/>			
				<input type="hidden" name="post_id" id="post_id" value="{{ article_id }}" />
				<input type="hidden" name="posts_modify_action" id="posts_modify_action" value="" />
			</div>
		</form>
		{% if comments_list %}
			<br/>
			<div id="comments_panel">
				<form action="/administrator/edit_comment" id="edit_comment" method="post" />
					Comments:<br/>
					{{comments_list|safe}}
					<input type="hidden" name="comment_id" id="comment_id" value="" />
					<input type="hidden" name="post_id" id="post_id_comments" value="{{article_id}}" />
					<input type="hidden" name="comments_modify_action" id="comments_modify_action" value="" />
				</form>
			</div>				
		{% endif %}
	{% else %}
		<form action="/administrator/new_post" id="new_post" method="post" />
			<label id="lbl_title" >Title: </label><br/>
			<textarea id="title" name="title" rows="3" cols="100"></textarea><br/>
			<label id="lbl_category" >Category: </label><br/>
			<input type="text" id="category" name="category" style="width:25em;" /><br/>
			<label id="lbl_content" >Content: </label><br/>
			<textarea id="content" name="content" rows="30" cols="100"></textarea><br/>
			<div class="label-tag-small">Hint:if you would like to write a code block you should enclose your code between &lt;code class="prettyprint linenums"&gt;YourCodeHere&lt;/code&gt; in the HTML plugin of the text editor</div><br/>
			<a href="javascript:;" onmousedown="newPost();" >[Save]</a>
			| [Set Visible] <input type="checkbox" name="visible" id="visible" checked="checked" />
		</form>
	{% endif %}
	</td>
	</tr>
</table>
</body>
</html>